//从键盘输入0~9之内的4个整数，计算由这4个整数组合成的整数的最大值和最小值
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int[] arr = new int[4];
        for (int i = 0; i < 4; i++) {
            arr[i] = scan.nextInt();
            if (!(arr[i] >= 0 && arr[i] <= 9)) {
                System.out.println("Numerical range error");
                return;
            }
        }
        //控制趟数
        for (int j = 0; j < 3; j++) {
            //一趟冒泡
            for (int k = 0; k < 3 - j; k++) {
                if (arr[k] > arr[k + 1]) {
                    arr[k] = arr[k] ^ arr[k + 1];
                    arr[k + 1] = arr[k] ^ arr[k + 1];
                    arr[k] = arr[k] ^ arr[k + 1];
                }
            }
        }
        int sum1 = 0;
        for (int i = 0; i < 4; i++) {
            sum1 = sum1 * 10 + arr[i];
        }
        int sum2 = 0;
        for (int i = 3; i >= 0; i--) {
            sum2 = sum2 * 10 + arr[i];
        }
        System.out.println(sum2 + " " + sum1);
    }
}
